import BasicLayout from "@/components/layout"
const importC = (path1: string | string[], path2: string) => {
  const path3 = handlePath(path1, path2)
  // 方式2 推荐
  const modules = import.meta.glob("@/views/**/**.tsx")
  // console.log('modules', modules, modules[`/src/views${path3}/index.tsx`])
  return modules[`/src/views${path3}/index.tsx`]
  // 方式1 警告
  // return () => import(/* @vite-ignore */`../views${path3}`)
}
let path1 = '';
export const importComponent = (path = '', page_type = 1) => {
  return page_type === 1 ? (path1 = path, BasicLayout) : importC(path1, path)
}

export const handlePath = (path1: string | string[], path2: string) => {
  if (path2.indexOf('/') === 0) {
    return path2
  }
  return path1 + '/' + path2
}